﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using System;
using System.ServiceModel;

namespace ConfExpert.Forms.Ithalat
{
    public partial class UnspedeHataBildir : XForm
    {
        string DosyaNo;
        string Referans;
        public UnspedeHataBildir(string DosyaNo, string Referans)
        {
            InitializeComponent();
            this.DosyaNo = DosyaNo;
            this.Referans =
            lblReferans.Text = Referans;
            txtOncelik.Text = "Normal";
        }

        private void UnspedeHataBildir_Load(object sender, EventArgs e)
        {
            btnBildir.ItemClick += btnBildir_ItemClick;
        }

        void btnBildir_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UnspedWS.KarbelDataWsdlSoapClient unsped = new UnspedWS.KarbelDataWsdlSoapClient();
            string userName = AppSession.UnspedUsername;
            string password = AppSession.UnspedPassword;
            BasicHttpBinding binding = (BasicHttpBinding)unsped.Endpoint.Binding;
            binding.MaxBufferSize = Int32.MaxValue;
            binding.MaxReceivedMessageSize = Int32.MaxValue;
            binding.SendTimeout = new TimeSpan(1, 0, 0);

            UnspedWS.KarbelDataWsdlSoapClient kd = new UnspedWS.KarbelDataWsdlSoapClient();
            UnspedWS.CagriDataGiris cg = new UnspedWS.CagriDataGiris();
            UnspedWS.Sonuc sn = new UnspedWS.Sonuc();

            cg.DosyaNo = DosyaNo;
            cg.Tip = "T";
            cg.SorunTuru = txtSorunTuru.Text;
            cg.Sorun = txtSorun.Text;
            cg.Oncelik = txtOncelik.Text;
            cg.Referans = Referans;

            int TicketId = 0;
            sn = kd.CagriGiris(userName, password, cg, out TicketId);

            ExecuteNonQuery("UpdUNS_Ticket", TicketId, cg.DosyaNo, cg.Tip, cg.SorunTuru, cg.Sorun, cg.Oncelik, cg.Referans, WhoAmI);
            this.DialogResult = System.Windows.Forms.DialogResult.OK;

        }
    }
}
